-
Notifications
You must be signed in to change notification settings - Fork 38.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support unqualified and partially qualified domain name in DNS query in Windows kube-proxy #41618
Conversation
Hi @JiangtianLi. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://github.com/kubernetes/kubernetes/wiki/CLA-FAQ to sign the CLA. Once you've signed, please reply here (e.g. "I signed it!") and we'll verify. Thanks.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
I signed it! Thanks. |
pkg/proxy/winuserspace/proxier.go
Outdated
@@ -28,7 +27,7 @@ import ( | |||
"github.com/golang/glog" | |||
|
|||
"k8s.io/apimachinery/pkg/types" | |||
utilerrors "k8s.io/apimachinery/pkg/util/errors" | |||
//utilerrors "k8s.io/apimachinery/pkg/util/errors" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete this if its no longer used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the confusion. My commit is based on Anthony's commit 302fa44 and 1410e06 so I had to include his commits here. In previous PR, the second commit 1410e06 was lost when I merge his and squash my commits. Now I did rebase and it looked fine. Please skip reviewing diff in commit 302fa44 and 1410e06.
pkg/proxy/winuserspace/proxier.go
Outdated
timeout time.Duration | ||
activeClients *clientCache | ||
dnsClients *dnsClientCache | ||
//nodePort int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete these if the are no longer used.
pkg/proxy/winuserspace/proxier.go
Outdated
netsh netsh.Interface | ||
hostIP net.IP | ||
proxyPorts PortAllocator | ||
//listenIP net.IP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too.
pkg/proxy/winuserspace/proxier.go
Outdated
//listenIP net.IP | ||
netsh netsh.Interface | ||
hostIP net.IP | ||
//proxyPorts PortAllocator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
pkg/proxy/winuserspace/proxier.go
Outdated
@@ -196,60 +188,64 @@ func (proxier *Proxier) SyncLoop() { | |||
|
|||
// Ensure that portals exist for all services. | |||
func (proxier *Proxier) ensurePortals() { | |||
proxier.mu.Lock() | |||
/*proxier.mu.Lock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete this block.
pkg/proxy/winuserspace/proxier.go
Outdated
spn := proxy.ServicePortName{NamespacedName: types.NamespacedName{Namespace: k.Namespace, Name: k.Name}, Port: k.Port} | ||
spnMap[spn] = true | ||
} | ||
for name := range spnMap { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This indirection seems weird, why not just proxier.loadBalancer.CleanupStaleStickySessions(name)
where you set spnMap[spn]=true
pkg/proxy/winuserspace/proxier.go
Outdated
var listenIPs []string | ||
listenIPs = append(listenIPs, service.Spec.ClusterIP) | ||
|
||
/*for _, ip := range service.Spec.ExternalIPs { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete dead code.
pkg/proxy/winuserspace/proxier.go
Outdated
// turn off the proxy | ||
err := proxier.stopProxy(serviceName, info) | ||
if err != nil { | ||
glog.Errorf("Failed to stop service %q: %v", serviceName, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bail out here?
pkg/proxy/winuserspace/proxier.go
Outdated
glog.Errorf("Failed to delete IP address for service %q, error %s", serviceName, err.Error()) | ||
} | ||
} else { | ||
// TODO(ajh) release the node port |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Address this todo?
pkg/proxy/winuserspace/proxier.go
Outdated
} | ||
si := &serviceInfo{ | ||
isAliveAtomic: 1, | ||
portal: portal{ip: listenIP, port: int(servicePort.Port), isExternal: false}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multi-line initializer.
pkg/proxy/winuserspace/proxier.go
Outdated
// only delete spn if all listen ips show inactive | ||
for k := range spnMap { | ||
if !spnMap[k] { | ||
proxier.loadBalancer.DeleteService(k) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above seems like you could inline this in the previous loop.
pkg/proxy/winuserspace/proxier.go
Outdated
if info.protocol != port.Protocol || info.portal.port != int(port.Port) || info.nodePort != int(port.NodePort) { | ||
return false | ||
} | ||
if !info.portal.ip.Equal(net.ParseIP(service.Spec.ClusterIP)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you delete all of this?
pkg/proxy/winuserspace/proxier.go
Outdated
@@ -402,6 +459,7 @@ func ipsEqual(lhs, rhs []string) bool { | |||
return true | |||
} | |||
|
|||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete commented out code.
func (udp *udpProxySocket) ProxyLoop(service proxy.ServicePortName, myInfo *serviceInfo, proxier *Proxier) { | ||
// TODO: use Go net dnsmsg library to walk DNS message format | ||
// DNS packet header | ||
type dnsHeader struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code could really use some unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. I will add unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added unit tests in a new commit.
/lgtm |
@k8s-bot bazel test this |
… in kube-proxy. kube-proxy iterates over DNS suffix search list and appends to DNS query for client.
@JiangtianLi can you add a descriptive title for this PR (e.g. "support dns search in windows proxy") Thanks |
@brendandburns Thanks for the reminder. I have modified the title. |
cc: @pires as well for a review |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED The following people have approved this PR: JiangtianLi, brendandburns, k8s-merge-robot Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
@k8s-bot kops aws e2e test this |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
@JiangtianLi: The following test(s) failed:
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Automatic merge from submit-queue (batch tested with PRs 42316, 41618, 42201, 42113, 42191) |
Automatic merge from submit-queue Fix the issue in Windows kube-proxy when processing unqualified name. This is for DNS client such as ping or iwr that validate name in response and original question. **What this PR does / why we need it**: This PR is an additional fix to #41618 and [the corresponding commit](b9dfb69). The DNS client such as nslookup does not validate name matching in response and original question. That works fine when we append DNS suffix to unqualified name in DNS query in Windows kube-proxy. However, for DNS client such as ping or Invoke-WebRequest that validates name in response and original question, the issue arises and the DNS query fails although the received DNS response has no error. This PR fixes the additional issue by restoring the original question name in DNS response. Further, this PR refactors DNS message routines by using miekg's DNS library. This PR affects the Windows kube-proxy only. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #42605 **Special notes for your reviewer**: **Release note**: ```release-note Fix DNS suffix search list support in Windows kube-proxy. ```
What this PR does / why we need it:
In Windows container networking, --dns-search is not currently supported on Windows Docker. Besides, even with --dns-suffix, inside Windows container DNS suffix is not appended to DNS query names. That makes unqualified domain name or partially qualified domain name in DNS query not able to resolve.
This PR provides a solution to resolve unqualified domain name or partially qualified domain name in DNS query for Windows container in Windows kube-proxy. It uses well-known Kubernetes DNS suffix as well host DNS suffix search list to append to the name in DNS query. DNS packet in kube-proxy UDP stream is modified as appropriate.
This PR affects the Windows kube-proxy only.
Special notes for your reviewer:
This PR is based on top of Anthony Howe's commit 48647fb, 0e37f0a and 7e2c71f which is already included in the PR 41487. Please only review commit b9dfb69.
Release note: